package com.example.ai_basedintelligentdiagnosisandtreatmentofchildren.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.ai_basedintelligentdiagnosisandtreatmentofchildren.R;
import com.example.ai_basedintelligentdiagnosisandtreatmentofchildren.model.MedicineCompleteItem;

import java.util.List;

public class MedicineCompeletedAdapter extends RecyclerView.Adapter<MedicineCompeletedAdapter.MedicineViewHolder> {
    private List<MedicineCompleteItem> medicineList;

    public MedicineCompeletedAdapter(List<MedicineCompleteItem> medicineList) {
        this.medicineList = medicineList;
    }

    @NonNull
    @Override
    public MedicineViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_medicine_complete, parent, false);
        return new MedicineViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull MedicineViewHolder holder, int position) {
        MedicineCompleteItem currentMedicine = medicineList.get(position);
        holder.patientNameLabel.setText("患者名：");
        holder.patientNameValue.setText(currentMedicine.getPatientName());
        holder.medicineNameLabel.setText("药品名：");
        holder.medicineNameValue.setText(currentMedicine.getMedicineName());
        holder.medicineTimeLabel.setText("时  间：");
        holder.medicineTimeValue.setText(currentMedicine.getMedicineTime());
    }

    @Override
    public int getItemCount() {
        return medicineList.size();
    }

    public static class MedicineViewHolder extends RecyclerView.ViewHolder {
        TextView patientNameLabel;
        TextView patientNameValue;
        TextView medicineNameLabel;
        TextView medicineNameValue;
        TextView medicineTimeLabel;
        TextView medicineTimeValue;

        public MedicineViewHolder(@NonNull View itemView) {
            super(itemView);
            patientNameLabel = itemView.findViewById(R.id.patientNameLabel);
            patientNameValue = itemView.findViewById(R.id.patientNameValue);
            medicineNameLabel = itemView.findViewById(R.id.medicineNameLabel);
            medicineNameValue = itemView.findViewById(R.id.medicineNameValue);
            medicineTimeLabel = itemView.findViewById(R.id.medicineTimeLabel);
            medicineTimeValue = itemView.findViewById(R.id.medicineTimeValue);
        }
    }
}
